library(ggplot2)
library(foreign)
# Female
# Read in data
d <- read.dta("res_contrib_socdem.dta")
d$group <- rownames(d)
d$model <- "Socio-Demographics"
d$model_id <- "1"

d2 <- read.dta("res_contrib_norms.dta")
d2$group <- rownames(d2)
d2$model <- "Social Norms"
d2$model_id <- "2"

d2[1,] <- c(0,0,0,0,0,0)
coef.vec.1<-d$estimate
se.vec.1 <- d$stderr
coef.vec.2<-d2$estimate
se.vec.2 <- d2$stderr

var.names <- c("Expected Contribution: Low (0 to 3 €/£/$)", "Expected Contribution: Medium (3 to 50 €/£/$)", "Expected Contribution: High (50 or more €/£/$)", "Female", "Age: 30-49", "Age: 50-69", "Age: 70+", "Income: Middle",
               "Income: High", "Education: High")

y.axis <- length(var.names):1
adjust <- .15
pdf("Figure3.pdf", encoding = "ISOLatin9.enc", width=11,height=8)

par(mar=c(4.5,20,1,2), lheight = .8)
plot(coef.vec.1, y.axis+adjust, type = "p", axes = F, xlab="", ylab = "", pch = 19, cex = 1.2, 
     xlim = c(min((coef.vec.1-qnorm(.975)*se.vec.1 -.1), (coef.vec.2-qnorm(.975)*se.vec.2 -.1), na.rm = T), 
    max((coef.vec.1+qnorm(.975)*se.vec.1 +.1), (coef.vec.2+qnorm(.975)*se.vec.2 +.1), na.rm = T)), 
     ylim = c(min(y.axis), max(y.axis)), main = "")
title(xlab="Change in Own Contribution (€, £, $)")
axis(1, at =seq(-5,55, by = 5), label = seq(-5,55, by = 5), cex.axis = 1.2)
axis(2, at = y.axis, label = var.names, las = 1, tick = T, cex.axis =1)
abline(h = y.axis, lty = 2, lwd = .5, col = "grey")
segments(coef.vec.1-qnorm(.975)*se.vec.1, y.axis+adjust, coef.vec.1+qnorm(.975)*se.vec.1, y.axis+adjust, lwd =  1.3)
abline(v=0, lty = 2) 
segments(coef.vec.2-qnorm(.975)*se.vec.2, y.axis-adjust, coef.vec.2+qnorm(.975)*se.vec.2, y.axis-adjust, lwd =  1.3)
points(coef.vec.2, y.axis-adjust, pch = 21, cex = 1.2, bg = "white" ) 
text(8, 3.7, "Model 1: Socio-Demographics Only (N=8,497)", adj = 0,cex  = 1)
points(7, 3.7, pch = 19, cex  = 1.2)
text(8, 3.3, "Model 2: Socio-Demographics and Expected Contribution (N=8,495)", adj = 0,cex  = 1)
points(7, 3.3, pch = 21, cex  = 1.2)
dev.off ()library(ggplot2)
library(foreign)
# Female
# Read in data
d <- read.dta("res_contrib_socdem.dta")
d$group <- rownames(d)
d$model <- "Socio-Demographics"
d$model_id <- "1"

d2 <- read.dta("res_contrib_norms.dta")
d2$group <- rownames(d2)
d2$model <- "Social Norms"
d2$model_id <- "2"

d2[1,] <- c(0,0,0,0,0,0)
coef.vec.1<-d$estimate
se.vec.1 <- d$stderr
coef.vec.2<-d2$estimate
se.vec.2 <- d2$stderr

var.names <- c("Expected Contribution: Low (0 to 3 €/£/$)", "Expected Contribution: Medium (3 to 50 €/£/$)", "Expected Contribution: High (50 or more €/£/$)", "Female", "Age: 30-49", "Age: 50-69", "Age: 70+", "Income: Middle",
               "Income: High", "Education: High")

y.axis <- length(var.names):1
adjust <- .15
pdf("Figure3.pdf", encoding = "ISOLatin9.enc", width=11,height=8)

par(mar=c(4.5,20,1,2), lheight = .8)
plot(coef.vec.1, y.axis+adjust, type = "p", axes = F, xlab="", ylab = "", pch = 19, cex = 1.2, 
     xlim = c(min((coef.vec.1-qnorm(.975)*se.vec.1 -.1), (coef.vec.2-qnorm(.975)*se.vec.2 -.1), na.rm = T), 
    max((coef.vec.1+qnorm(.975)*se.vec.1 +.1), (coef.vec.2+qnorm(.975)*se.vec.2 +.1), na.rm = T)), 
     ylim = c(min(y.axis), max(y.axis)), main = "")
title(xlab="Change in Own Contribution (€, £, $)")
axis(1, at =seq(-5,55, by = 5), label = seq(-5,55, by = 5), cex.axis = 1.2)
axis(2, at = y.axis, label = var.names, las = 1, tick = T, cex.axis =1)
abline(h = y.axis, lty = 2, lwd = .5, col = "grey")
segments(coef.vec.1-qnorm(.975)*se.vec.1, y.axis+adjust, coef.vec.1+qnorm(.975)*se.vec.1, y.axis+adjust, lwd =  1.3)
abline(v=0, lty = 2) 
segments(coef.vec.2-qnorm(.975)*se.vec.2, y.axis-adjust, coef.vec.2+qnorm(.975)*se.vec.2, y.axis-adjust, lwd =  1.3)
points(coef.vec.2, y.axis-adjust, pch = 21, cex = 1.2, bg = "white" ) 
text(8, 3.7, "Model 1: Socio-Demographics Only (N=8,497)", adj = 0,cex  = 1)
points(7, 3.7, pch = 19, cex  = 1.2)
text(8, 3.3, "Model 2: Socio-Demographics and Expected Contribution (N=8,495)", adj = 0,cex  = 1)
points(7, 3.3, pch = 21, cex  = 1.2)
dev.off ()